﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class InventoryTracker_DD : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // This is because Table[1] contains Categories

        GridView1.DataSource = GetDataSet().Tables[1];

        GridView1.DataBind(); 
    }

    private DataSet GetDataSet()
    {
        //        string query = @"SELECT ItemCode,ItemName FROM MaterialMaster m
        //            Select ItemDescription FROM MaterialMaster n;
        string query = @"SELECT p.CategoryID,p.ProductID, p.ProductName FROM Products p

               SELECT c.CategoryID,c.CategoryName FROM Categories c";
        string connectionString = @"Server=.\SQLEXPRESS;Database=F:\inv\App_Data\TimeTracker.mdf;;Trusted_Connection=true";
         
        SqlConnection myConnection = new SqlConnection(connectionString);

        SqlDataAdapter ad = new SqlDataAdapter(query, myConnection);

        DataSet ds = new DataSet();

        ad.Fill(ds);

        return ds;

    }

}
